import java.util.Random;

/**
 * 二维数组
 * 1、定义：类型[][] 数组名=new 类型[行数][列数]
 */
public class Array4 {
    //随机生成数组
    static void setRandom(int[][] a){
        Random r=new Random();
        for (int i=0;i<a.length;i++){
            for (int j=0;j<a[i].length;j++){
                a[i][j]=r.nextInt(100);
            }
        }
    }
    //找出每一行的最小值存入新的数组
    static void findMin(int[][] a,int[] b){
        for (int i=0;i<a.length;i++){
            int min=a[i][0];
            for (int j=1;j<a[i].length;j++){
                if (a[i][j]<min) min=a[i][j];
            }
            b[i]=min;
        }
    }
    //行列互换
    static void exchage(int[][] c){
        for (int i=0;i<c.length;i++){
            //for (int j=0;i!=j&&j<c[i].length;j++){
            for (int j=0;j<i;j++){
                int t=c[i][j];
                c[i][j]=c[j][i];
                c[j][i]=t;
            }
        }
    }
    //杨辉三角
    static void jisuan(int[][] d){
        for (int i=0;i<d.length;i++) {
            d[i] = new int[i + 1];
            d[i][0] = 1;
            d[i][i] = 1;
        }
        for (int i=2;i<d.length;i++){
            for (int j=1;j<i;j++){
                   d[i][j]=d[i-1][j-1]+d[i-1][j];
            }
        }
    }
    public static void main(String[] args){
        int[][] a=new int[3][5];
        int[] b=new int[a.length];
        int[][] c=new int[3][3];
        int[][] d=new int[6][];
        /*out(a);
        setRandom(a);
        out(a);
        findMin(a,b);
        out(b);
        setRandom(c);
        out(c);
        exchage(c);
        out(c);*/
        System.out.println("-------------------");
        jisuan(d);
        out(d);

    }
    static void out(int[] x){
        for (int e: x){
            System.out.print(e+" ");
        }
        System.out.println();
    }
    static void out(int[][] a){
        for (int i=0;i<a.length;i++){
            int j;
            for (j=0;j<a[i].length;j++){
                System.out.print(a[i][j]+" ");
            }
            System.out.println();
        }
    }

}
